//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using Mindscape.BackgroundMotion.Website.Controllers;
using Mindscape.BackgroundMotion.Website.Infrastructure;

namespace Mindscape.BackgroundMotion.Website.Views
{
  public sealed class ModeratePresenter : PresenterBase<IModerateView, IContributionController>
  {
    /// <summary>
    /// This method is invoked by the view everytime it loads
    /// </summary>
    public override void OnViewLoaded()
    {
      View.UnmoderatedContributions = Controller.GetUnmoderatedContributions();
    }

    /// <summary>
    /// Approves an item of content.
    /// </summary>
    /// <remarks>
    /// Content refers to a <see ref="Contribution"/> instance
    /// </remarks>
    /// <param name="id">The id.</param>
    public void ApproveContent(int id)
    {
      Controller.ApproveContribution(id);
      View.UnmoderatedContributions = Controller.GetUnmoderatedContributions();
    }

    /// <summary>
    /// Deletes an item of content.
    /// </summary>
    /// <remarks>
    /// Content refers to a <see ref="Contribution"/> instance
    /// </remarks>
    /// <param name="id">The id.</param>
    public void DeleteContent(int id)
    {
      Controller.DeleteContribution(id);
      View.UnmoderatedContributions = Controller.GetUnmoderatedContributions();
    }
  }
}